<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/12/18
  Time: 10:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html";charset="gb2312">
    <title>CoolMeeting会议管理系统</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/styles/common.css"/>
    <%--    <script type="text/javascript" src="${pageContext.request.contextPath }/js/insertpwd.js" ></script>--%>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js" ></script>
    <script language="JavaScript">

        // function getpwda(){
        //     var pwd =document.getElementById('password');
        //     if(pwd.value.length!=0){
        //         document.getElementById('pwd').innerHTML='';
        //         return true;
        //     }
        //     document.getElementById('pwd').innerHTML='密码不能为空';
        //     return false;
        // }

        // function check(obj){
        //     var pass1 =document.getElementById("password").value;
        //     var pass2 =obj.value;
        //     if(pass1==pass2){
        //         document.getElementById("tip").innerText="";
        //     }else {
        //         document.getElementById("tip").innerText="两次密码不一致";
        //     }
        // }
        // }
        //部门ajax
        $(function(){
            $.ajax({
                type:"get",
                url:$("#path").val()+"/SelectDeptnameServlet",
                async:true,
                dataType:"json",
                success:function(data){
                    var pro =$("select[name=department]");
                    //清空子节点
                    pro.empty();
                    $.each(data,function(i,department){
                        var optionNode ='<option value="'+department.departmentid+'">'+department.departmentname+'</option>';
                        pro.append(optionNode);
                    });
                },
                error:function(xmlHttpRequest){
                    alert(xmlHttpRequest.status);
                }
            });
        });

        function beforeSubmit(form){
            if(form.employeename.value==''){
                alert('用户姓名不能为空！');
                form.employeename.focus();
                return false;
            }
            if(form.accountname.value==''){
                alert('账户名不能为空！');
                form.accountname.focus();
                return false;
            }
            if(form.password.value==''){
                alert('密码不能为空！');
                form.password.focus();
                return false;
            }
            if(form.password.value.length<6){
                alert('密码至少为6位，请重新输入！');
                form.password.focus();
                return false;
            }
            if(form.confirm.value==''){
                alert('确认密码不能为空！');
                form.password.focus();
                return false;
            }
            if(form.password.value!=form.confirm.value) {
                alert('你两次输入的密码不一致，请重新输入！');
                form.confirm.focus();
                return false;
            }
            if(form.phone.value==''){
                alert('电话号不能为空！');
                form.phone.focus();
                return false;
            }
            if(form.email.value==''){
                alert('邮箱号不能为空！');
                form.email.focus();
                return false;
            }
            return true;
        }

    </script>

    <style type="text/css">

    </style>
</head>
<body>
<div class="page-content">
    <div class="content-nav">
        人员管理 > 员工注册
    </div>
    <form action="${pageContext.request.contextPath }/insertEmpServlet" onSubmit="return beforeSubmit(this);">
        <fieldset>
            <legend>员工信息</legend>
            <table class="formtable" style="width:50%">
                <tr>
                    <td>姓名：</td>
                    <td>
                        <input type="text" id="employeename" name="employeename" maxlength="20"/>
                    </td>
                </tr>
                <tr>
                    <td>账户名：</td>
                    <td>
                        <input type="text" id="accountname" name="accountname" maxlength="20"/>
                    </td>
                </tr>
                <tr>
                    <td>密码：</td>
                    <td>
                        <input type="password" id="password" name="password" maxlength="20" placeholder="请输入6位以上的密码" onblur="getpwda()"/>
                        <span id="pwd" ></span>
                    </td>
                </tr>
                <tr>
                    <td>确认密码：</td>
                    <td>
                        <input type="password" id="confirm" name="confirm" maxlength="20" onblur="check(this)"/>
                        <span id="tip"></span>
                    </td>
                </tr>
                <tr>
                    <td>部门：</td>
                    <td>
                        <%--<input type="text" id="dept" maxlength="20"/>--%>
                        <input type="hidden" id="path"  value="${pageContext.request.contextPath}">
                        <select name="department">

                        </select>
                    </td>


                </tr>
                <tr>
                    <td>联系电话：</td>
                    <td>
                        <input type="text" id="phone" name="phone" maxlength="20"/>
                    </td>
                </tr>
                <tr>
                    <td>电子邮件：</td>
                    <td>
                        <input type="text" id="email" name="email" maxlength="20"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="6" class="command">
                        <input type="submit" class="clickbutton" value="注册"/>
                        <input type="reset" class="clickbutton" value="重置"/>
                    </td>

                </tr>



            </table>
            <span style="color: red" >   ${msg }   </span>
        </fieldset>
    </form>
</div>
</body>

</html>